package com.des1gn.consumer;

import com.alibaba.fastjson.JSONObject;
import com.des1gn.common.bean.RetryErrorMqMessageDto;
import com.des1gn.common.constant.MqConstants;
import com.des1gn.processor.MqPostProcessor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.kafka.annotation.KafkaListener;
import org.springframework.stereotype.Component;

/**
 * @ClassName MpConsumer
 * @Description kafka consumer
 * @Author Des1gn
 * @Date 2023/4/11 19:47
 * @Version 1.0
 **/
@Slf4j
@Component
public class MqConsumer {


    @KafkaListener(topics = {MqConstants.RETRY_ERROR_GROUP})
    public void mpConsumer(String message){
        try {
            log.info("kafka consumer mp-> {}",message);
            RetryErrorMqMessageDto retryErrorMqMessageDto = JSONObject.parseObject(message, RetryErrorMqMessageDto.class);
            MqPostProcessor.doProcess(retryErrorMqMessageDto);
        }catch (Exception e){
            log.error("kafka consumer read error mq-{}",e);
        }
    }


}
